package com.android.lovely.data

import com.android.lovely.api.service.userService
import com.android.lovely.framework.doContinuousOperation
import com.kotlin.extensions.coroutine.CoroutineExt.launchSafety
import com.kotlin.extensions.coroutine.applicationScope
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class LovelyTask(
    @Json(name = "icon") val icon: String = "",
    @Json(name = "max_num") val maxNum: Int = 0,
    @Json(name = "msg") val msg: String = "",
    @Json(name = "num") val num: Int = 0,
    @Json(name = "point") val point: String = "",
    @Json(name = "title") val title: String = "",
    @Json(name = "type") val type: String = ""
)

@JsonClass(generateAdapter = true)
data class Share(
    @Json(name = "invite_code") val inviteCode: String = "",
    @Json(name = "invite_uid") val inviteUid: Int = 0,
    @Json(name = "invite_user_code") val inviteUserCode: String = "",
    @Json(name = "lang") val lang: String = "",
    @Json(name = "share_content") val shareContent: String = "",
    @Json(name = "status") val status: Int = 0
)

var shareInfo: Share? = null

fun getInviteInfo() {
    applicationScope.launchSafety {
        doContinuousOperation {
            shareInfo = userService.getInviteInfo()
        }
    }
}